home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 118 / cd-rom 118.iso / aplic / open / openofficeorg2.cab / styles.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2005-01-31  |  30.4 KB  |  571 lines

  1. ∩╗┐<?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.    $RCSfile: styles.xsl,v $
  5.  
  6.    $Revision: 1.6 $
  7.  
  8.    last change: $Author: rt $ $Date: 2005/01/28 15:23:04 $
  9.  
  10.    The Contents of this file are made available subject to the terms of
  11.    either of the following licenses
  12.  
  13.           - GNU Lesser General Public License Version 2.1
  14.           - Sun Industry Standards Source License Version 1.1
  15.  
  16.    Sun Microsystems Inc., October, 2000
  17.  
  18.    GNU Lesser General Public License Version 2.1
  19.    =============================================
  20.    Copyright 2000 by Sun Microsystems, Inc.
  21.    901 San Antonio Road, Palo Alto, CA 94303, USA
  22.  
  23.    This library is free software; you can redistribute it and/or
  24.    modify it under the terms of the GNU Lesser General Public
  25.    License version 2.1, as published by the Free Software Foundation.
  26.  
  27.    This library is distributed in the hope that it will be useful,
  28.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  29.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  30.    Lesser General Public License for more details.
  31.  
  32.    You should have received a copy of the GNU Lesser General Public
  33.    License along with this library; if not, write to the Free Software
  34.    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  35.    MA  02111-1307  USA
  36.  
  37.  
  38.    Sun Industry Standards Source License Version 1.1
  39.    =================================================
  40.    The contents of this file are subject to the Sun Industry Standards
  41.    Source License Version 1.1 (the "License"); You may not use this file
  42.    except in compliance with the License. You may obtain a copy of the
  43.    License at http://www.openoffice.org/license.html.
  44.  
  45.    Software provided under this License is provided on an "AS IS" basis,
  46.    WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
  47.    WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
  48.    MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
  49.    See the License for the specific provisions governing your rights and
  50.    obligations concerning the Software.
  51.  
  52.    The Initial Developer of the Original Code is: Sun Microsystems, Inc.
  53.  
  54.    Copyright ┬⌐ 2002 by Sun Microsystems, Inc.
  55.  
  56.    All Rights Reserved.
  57.  
  58.    Contributor(s): _______________________________________
  59.  
  60. -->
  61. <!--
  62.     For further documentation and updates visit http://xml.openoffice.org/sx2ml
  63. -->
  64. <xsl:stylesheet version="1.0"
  65.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  66.     xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
  67.     xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0"
  68.     xmlns:dc="http://purl.org/dc/elements/1.1/"
  69.     xmlns:dom="http://www.w3.org/2001/xml-events"
  70.     xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
  71.     xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
  72.     xmlns:fo="http://www.w3.org/1999/XSL/Format"
  73.     xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
  74.     xmlns:math="http://www.w3.org/1998/Math/MathML"
  75.     xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
  76.     xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
  77.     xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
  78.     xmlns:ooo="http://openoffice.org/2004/office"
  79.     xmlns:oooc="http://openoffice.org/2004/calc"
  80.     xmlns:ooow="http://openoffice.org/2004/writer"
  81.     xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
  82.     xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
  83.     xmlns:svg="http://www.w3.org/2000/svg"
  84.     xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
  85.     xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
  86.     xmlns:xlink="http://www.w3.org/1999/xlink"
  87.     xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  88.     exclude-result-prefixes="chart config dc dom dr3d draw fo form math meta number office ooo oooc ooow script style svg table text xlink">
  89.  
  90.     <!-- Used in case of 'style:map', conditional formatting, where a style references to another -->
  91.     <xsl:key name="styles" match="/*/office:styles/style:style | /*/office:automatic-styles/style:style" use="@style:name" />
  92.     <!--
  93.         Mapping of OOo style:name and style:family to excel ss:ID
  94.         Styles form style:style map from style:name to ss:Name
  95.         style:parent-style map to ss:Parent
  96.     -->
  97.     <!--   default styles of the application
  98.     <xsl:template match="style:default-style" mode="styles" >
  99.         <xsl:call-template name="style:style">
  100.             <xsl:with-param name="styleName" select="'Default'" />
  101.         </xsl:call-template>
  102.     </xsl:template>
  103.      -->
  104.  
  105.     <xsl:template match="style:style" name="style:style" mode="styles">
  106.         <xsl:param name="isAutomatic" />
  107.         <xsl:param name="styleName" select="@style:name" />
  108.  
  109.         <xsl:element name="Style">
  110.             <xsl:attribute name="ss:ID">
  111.                 <xsl:value-of select="$styleName" />
  112.             </xsl:attribute>
  113.             <xsl:if test="not($isAutomatic)">
  114.                 <xsl:choose>
  115.                     <xsl:when test="$styleName='Default'">
  116.                         <xsl:attribute name="ss:Name"><xsl:value-of select="'Normal'" /></xsl:attribute>
  117.                     </xsl:when>
  118.                     <xsl:otherwise>
  119.                         <xsl:attribute name="ss:Name"><xsl:value-of select="$styleName" /></xsl:attribute>
  120.                     </xsl:otherwise>
  121.                 </xsl:choose>
  122.             </xsl:if>
  123.             <xsl:if test="@style:parent-style-name">
  124.                 <xsl:attribute name="ss:Parent"><xsl:value-of select="@style:parent-style-name" /></xsl:attribute>
  125.             </xsl:if>
  126.  
  127.             <xsl:variable name="styleProperties" select="key('styles', $styleName)/*" />
  128.             <xsl:call-template name="Alignment">
  129.                 <xsl:with-param name="styleProperties" select="$styleProperties" />
  130.             </xsl:call-template>
  131.             <xsl:call-template name="Border">
  132.                 <xsl:with-param name="styleProperties" select="$styleProperties" />
  133.             </xsl:call-template>
  134.             <xsl:call-template name="Font">
  135.                 <xsl:with-param name="styleProperties" select="$styleProperties" />
  136.             </xsl:call-template>
  137.             <xsl:call-template name="Interior">
  138.                 <xsl:with-param name="styleProperties" select="$styleProperties" />
  139.             </xsl:call-template>
  140.             <xsl:call-template name="NumberFormat">
  141.                 <xsl:with-param name="styleProperties" select="$styleProperties" />
  142.             </xsl:call-template>
  143.         </xsl:element>
  144.     </xsl:template>
  145.  
  146.     <xsl:key match="/*/office:styles/number:date-style |
  147.                     /*/office:styles/number:time-style |
  148.                     /*/office:styles/number:number-style |
  149.                     /*/office:styles/number:percentage-style |
  150.                     /*/office:styles/number:currency-style |
  151.                     /*/office:automatic-styles/number:date-style |
  152.                     /*/office:automatic-styles/number:time-style |
  153.                     /*/office:automatic-styles/number:number-style  |
  154.                     /*/office:automatic-styles/number:percentage-style |
  155.                     /*/office:automatic-styles/number:currency-style" name="number-style" use="@style:name" />
  156.     <xsl:template name="NumberFormat">
  157.         <xsl:if test="@style:data-style-name">
  158.             <xsl:variable name="numberStyleName" select="@style:data-style-name" />
  159.             <xsl:variable name="numberStyle" select="key('number-style', $numberStyleName)" />
  160.  
  161.             <xsl:element name="NumberFormat">
  162.                 <xsl:attribute name="ss:Format">
  163.                 <xsl:choose>
  164.                     <xsl:when test="not($numberStyle/node())">
  165.                         <!-- Excel2003sp1 issue: 'General' and 'General Number' is not supported -->
  166.                          <xsl:text>General</xsl:text>
  167.                     </xsl:when>
  168.                     <xsl:when test="name($numberStyle) = 'number:number-style'">
  169.                         <xsl:choose>
  170.                             <xsl:when test="$numberStyle/number:scientific-number">
  171.                                 <xsl:text>Scientific</xsl:text>
  172.                             </xsl:when>
  173.                             <!-- Excel2003sp1 issue: 'General Number' not supported -->
  174.                             <xsl:when test="$numberStyle/number:number/@number:decimal-places and
  175.                                             $numberStyle/number:number/@number:decimal-places='0'">
  176.                                 <xsl:text>General</xsl:text>
  177.                             </xsl:when>
  178.                             <xsl:when test="$numberStyle/number:text">
  179.                                 <xsl:choose>
  180.                                     <xsl:when test="$numberStyle/number:text = 'No' or $numberStyle/number:text = 'Nein'">
  181.                                         <xsl:text>Yes/No</xsl:text>
  182.                                     </xsl:when>
  183.                                     <xsl:when test="$numberStyle/number:text = 'False' or $numberStyle/number:text = 'Falsch'">
  184.                                         <xsl:text>True/False</xsl:text>
  185.                                     </xsl:when>
  186.                                     <xsl:when test="$numberStyle/number:text = 'Off' or $numberStyle/number:text = 'Aus'">
  187.                                         <xsl:text>On/Off</xsl:text>
  188.                                     </xsl:when>
  189.                                     <!-- Excel2003sp1 issue: currency is saved as 'float' -->
  190.                                     <xsl:when test="$numberStyle/number:currency-symbol">
  191.                                         <xsl:choose>
  192.                                             <xsl:when test="contains($numberStyle/number:currency-symbol, 'Γé¼')">
  193.                                                 <xsl:text>Euro Currency</xsl:text>
  194.                                             </xsl:when>
  195.                                             <xsl:otherwise>
  196.                                                 <xsl:text>Currency</xsl:text>
  197.                                             </xsl:otherwise>
  198.                                         </xsl:choose>
  199.                                     </xsl:when>
  200.                                     <!-- Excel2003sp1 issue: 'Currency' is saved as 'float' -->
  201.                                     <xsl:when test="contains($numberStyle/number:text, '$')">
  202.                                         <xsl:text>Currency</xsl:text>
  203.                                     </xsl:when>
  204.                                     <!-- OASIS XML adapation -->
  205.                                     <xsl:otherwise>
  206.                                         <xsl:text>General</xsl:text>
  207.                                     </xsl:otherwise>
  208.                                 </xsl:choose>
  209.                             </xsl:when>
  210.                             <xsl:when test="$numberStyle/number:grouping">
  211.                                 <xsl:text>Standard</xsl:text>
  212.                             </xsl:when>
  213.                             <xsl:otherwise>
  214.                                 <xsl:text>Fixed</xsl:text>
  215.                             </xsl:otherwise>
  216.                         </xsl:choose>
  217.                     </xsl:when>
  218.                     <xsl:when test="name($numberStyle) = 'number:time-style'">
  219.                         <xsl:choose>
  220.                             <xsl:when test="$numberStyle/number:am-pm">
  221.                                 <xsl:choose>
  222.                                     <xsl:when test="$numberStyle/number:seconds">
  223.                                         <xsl:text>Long Time</xsl:text>
  224.                                     </xsl:when>
  225.                                     <xsl:otherwise>
  226.                                         <xsl:text>Medium Time</xsl:text>
  227.                                     </xsl:otherwise>
  228.                                 </xsl:choose>
  229.                             </xsl:when>
  230.                             <xsl:otherwise>
  231.                                 <xsl:text>Short Time</xsl:text>
  232.                             </xsl:otherwise>
  233.                         </xsl:choose>
  234.                     </xsl:when>
  235.                     <xsl:when test="name($numberStyle) = 'number:percentage-style'">
  236.                         <xsl:text>Percent</xsl:text>
  237.                     </xsl:when>
  238.                     <xsl:when test="name($numberStyle) = 'number:currency-style'">
  239.                         <xsl:choose>
  240.                             <xsl:when test="contains($numberStyle/number:currency-symbol, 'Γé¼')">
  241.                                 <xsl:text>Euro Currency</xsl:text>
  242.                             </xsl:when>
  243.                             <xsl:otherwise>
  244.                                 <xsl:text>Currency</xsl:text>
  245.                             </xsl:otherwise>
  246.                         </xsl:choose>
  247.                     </xsl:when>
  248.                     <xsl:otherwise>
  249.                         <xsl:choose>
  250.                             <xsl:when test="$numberStyle/number:month">
  251.                                 <xsl:choose>
  252.                                     <xsl:when test="$numberStyle/number:month/@number:textual and
  253.                                                     $numberStyle/number:month/@number:textual=true()">
  254.                                         <xsl:text>Medium Date</xsl:text>
  255.                                         <!--  Excel2003 sp1 issue: No difference between 'Long Date' and 'Medium Date' -->
  256.                                     </xsl:when>
  257.                                     <xsl:when test="$numberStyle/number:hours">
  258.                                         <xsl:text>General Date</xsl:text>
  259.                                     </xsl:when>
  260.                                     <xsl:when test="$numberStyle/number:year/@number:style and
  261.                                                     $numberStyle/number:year/@number:style='long'">
  262.                                         <xsl:text>Short Date</xsl:text>
  263.                                     </xsl:when>
  264.                                     <!-- OASIS XML adapation -->
  265.                                     <xsl:otherwise>
  266.                                         <xsl:text>Short Date</xsl:text>
  267.                                     </xsl:otherwise>
  268.                                 </xsl:choose>
  269.                             </xsl:when>
  270.                             <!-- OASIS XML adapation -->
  271.                             <xsl:otherwise>
  272.                                 <xsl:text>General</xsl:text>
  273.                             </xsl:otherwise>
  274.                         </xsl:choose>
  275.                     </xsl:otherwise>
  276.                 </xsl:choose>
  277.                 </xsl:attribute>
  278.             </xsl:element>
  279.         </xsl:if>
  280.     </xsl:template>
  281.  
  282.     <xsl:template name="Alignment">
  283.         <xsl:param name="styleProperties" />
  284.  
  285.         <!-- An empty Alignment element, might overwrite parents setting by
  286.              the default attributes -->
  287.         <xsl:if test="$styleProperties/@fo:text-align or
  288.                       $styleProperties/@style:vertical-align or
  289.                       $styleProperties/@fo:wrap-option or
  290.                       $styleProperties/@fo:margin-left or
  291.                       $styleProperties/@style:rotation-angle or
  292.                       $styleProperties/@style:direction">
  293.             <xsl:element name="Alignment">
  294.                 <xsl:if test="$styleProperties/@fo:text-align">
  295.                     <xsl:attribute name="ss:Horizontal">
  296.                         <xsl:choose>
  297.                             <xsl:when test="$styleProperties/@fo:text-align = 'center'">Center</xsl:when>
  298.                             <xsl:when test="$styleProperties/@fo:text-align = 'end'">Right</xsl:when>
  299.                             <xsl:when test="$styleProperties/@fo:text-align = 'justify'">Justify</xsl:when>
  300.                             <xsl:otherwise>Left</xsl:otherwise>
  301.                         </xsl:choose>
  302.                     </xsl:attribute>
  303.                 </xsl:if>
  304.                 <xsl:if test="$styleProperties/@style:vertical-align">
  305.                     <xsl:attribute name="ss:Vertical">
  306.                         <xsl:choose>
  307.                             <xsl:when test="$styleProperties/@style:vertical-align = 'top'">Top</xsl:when>
  308.                             <xsl:when test="$styleProperties/@style:vertical-align = 'bottom'">Bottom</xsl:when>
  309.                             <xsl:when test="$styleProperties/@style:vertical-align = 'middle'">Center</xsl:when>
  310.                             <xsl:otherwise>Automatic</xsl:otherwise>
  311.                         </xsl:choose>
  312.                     </xsl:attribute>
  313.                 </xsl:if>
  314.                 <xsl:if test="$styleProperties/@fo:wrap-option = 'wrap'">
  315.                     <xsl:attribute name="ss:WrapText">1</xsl:attribute>
  316.                 </xsl:if>
  317.                 <xsl:if test="$styleProperties/@fo:margin-left">
  318.                     <xsl:attribute name="ss:Indent">
  319.                         <xsl:variable name="margin">
  320.                             <xsl:call-template name="convert2pt">
  321.                                 <xsl:with-param name="value" select="$styleProperties/@fo:margin-left" />
  322.                                 <xsl:with-param name="rounding-factor" select="1" />
  323.                             </xsl:call-template>
  324.                         </xsl:variable>
  325.                         <!-- one ss:Indent is equal to 10 points -->
  326.                         <xsl:value-of select="number($margin) div 10"/>
  327.                     </xsl:attribute>
  328.                 </xsl:if>
  329.                 <!-- Excel is only able to rotate between 90 and -90 degree (inclusive).
  330.                      Other degrees will be mapped by 180 degrees -->
  331.                 <xsl:if test="$styleProperties/@style:rotation-angle">
  332.                     <xsl:attribute name="ss:Rotate">
  333.                         <xsl:choose>
  334.                             <xsl:when test="$styleProperties/@style:rotation-angle > 90">
  335.                                 <xsl:choose>
  336.                                     <xsl:when test="$styleProperties/@style:rotation-angle >= 270">
  337.                                         <xsl:value-of select="$styleProperties/@style:rotation-angle - 360" />
  338.                                     </xsl:when>
  339.                                     <xsl:otherwise>
  340.                                         <xsl:value-of select="$styleProperties/@style:rotation-angle - 180" />
  341.                                     </xsl:otherwise>
  342.                                 </xsl:choose>
  343.                             </xsl:when>
  344.                             <xsl:when test="$styleProperties/@style:rotation-angle < -90">
  345.                                 <xsl:choose>
  346.                                     <xsl:when test="$styleProperties/@style:rotation-angle <= -270">
  347.                                         <xsl:value-of select="$styleProperties/@style:rotation-angle + 360" />
  348.                                     </xsl:when>
  349.                                     <xsl:otherwise>
  350.                                         <xsl:value-of select="$styleProperties/@style:rotation-angle + 180" />
  351.                                     </xsl:otherwise>
  352.                                 </xsl:choose>
  353.                             </xsl:when>
  354.                             <xsl:otherwise>
  355.                                 <xsl:value-of select="$styleProperties/@style:rotation-angle" />
  356.                             </xsl:otherwise>
  357.                         </xsl:choose>
  358.                     </xsl:attribute>
  359.                 </xsl:if>
  360.                 <xsl:if test="$styleProperties/@style:direction = 'ttb'">
  361.                     <xsl:attribute name="ss:VerticalText">1</xsl:attribute>
  362.                 </xsl:if>
  363.             </xsl:element>
  364.         </xsl:if>
  365.     </xsl:template>
  366.  
  367.  
  368.     <xsl:template name="Border">
  369.         <xsl:param name="styleProperties" />
  370.  
  371.         <!-- An empty border element, might overwrite parents setting by
  372.              the default attributes -->
  373.         <xsl:if test="$styleProperties/@fo:border or
  374.                       $styleProperties/@fo:border-bottom or
  375.                       $styleProperties/@fo:border-left or
  376.                       $styleProperties/@fo:border-right or
  377.                       $styleProperties/@fo:border-top">
  378.             <xsl:element name="Borders">
  379.                 <xsl:if test="$styleProperties/@fo:border-bottom and not($styleProperties/@fo:border-bottom = 'none')">
  380.                     <xsl:element name="Border">
  381.                         <xsl:attribute name="ss:Position">Bottom</xsl:attribute>
  382.                         <xsl:call-template name="border-attributes">
  383.                             <xsl:with-param name="border_properties" select="$styleProperties/@fo:border-bottom" />
  384.                         </xsl:call-template>
  385.                     </xsl:element>
  386.                 </xsl:if>
  387.                 <xsl:if test="$styleProperties/@fo:border-left and not($styleProperties/@fo:border-left = 'none')">
  388.                     <xsl:element name="Border">
  389.                         <xsl:attribute name="ss:Position">Left</xsl:attribute>
  390.                         <xsl:call-template name="border-attributes">
  391.                             <xsl:with-param name="border_properties" select="$styleProperties/@fo:border-left" />
  392.                         </xsl:call-template>
  393.                     </xsl:element>
  394.                 </xsl:if>
  395.                 <xsl:if test="$styleProperties/@fo:border-right and not($styleProperties/@fo:border-right = 'none')">
  396.                     <xsl:element name="Border">
  397.                         <xsl:attribute name="ss:Position">Right</xsl:attribute>
  398.                         <xsl:call-template name="border-attributes">
  399.                             <xsl:with-param name="border_properties" select="$styleProperties/@fo:border-right" />
  400.                         </xsl:call-template>
  401.                     </xsl:element>
  402.                 </xsl:if>
  403.                 <xsl:if test="$styleProperties/@fo:border-top  and not($styleProperties/@fo:border-top = 'none')">
  404.                     <xsl:element name="Border">
  405.                         <xsl:attribute name="ss:Position">Top</xsl:attribute>
  406.                         <xsl:call-template name="border-attributes">
  407.                             <xsl:with-param name="border_properties" select="$styleProperties/@fo:border-top" />
  408.                         </xsl:call-template>
  409.                     </xsl:element>
  410.                 </xsl:if>
  411.                 <!-- write out all table border  -->
  412.                 <xsl:if test="$styleProperties/@fo:border and not($styleProperties/@fo:border = 'none')">
  413.                     <xsl:element name="Border">
  414.                         <xsl:attribute name="ss:Position">Bottom</xsl:attribute>
  415.                         <xsl:call-template name="border-attributes">
  416.                             <xsl:with-param name="border_properties" select="$styleProperties/@fo:border" />
  417.                         </xsl:call-template>
  418.                     </xsl:element>
  419.                     <xsl:element name="Border">
  420.                         <xsl:attribute name="ss:Position">Left</xsl:attribute>
  421.                         <xsl:call-template name="border-attributes">
  422.                             <xsl:with-param name="border_properties" select="$styleProperties/@fo:border" />
  423.                         </xsl:call-template>
  424.                     </xsl:element>
  425.                     <xsl:element name="Border">
  426.                         <xsl:attribute name="ss:Position">Right</xsl:attribute>
  427.                         <xsl:call-template name="border-attributes">
  428.                             <xsl:with-param name="border_properties" select="$styleProperties/@fo:border" />
  429.                         </xsl:call-template>
  430.                     </xsl:element>
  431.                     <xsl:element name="Border">
  432.                         <xsl:attribute name="ss:Position">Top</xsl:attribute>
  433.                         <xsl:call-template name="border-attributes">
  434.                             <xsl:with-param name="border_properties" select="$styleProperties/@fo:border" />
  435.                         </xsl:call-template>
  436.                     </xsl:element>
  437.                 </xsl:if>
  438.             </xsl:element>
  439.         </xsl:if>
  440.     </xsl:template>
  441.  
  442.  
  443.     <xsl:template name="border-attributes">
  444.         <xsl:param name="border_properties" />
  445.  
  446.         <xsl:variable name="border-width">
  447.             <xsl:call-template name="convert2cm">
  448.                 <xsl:with-param name="value" select="substring-before($border_properties, ' ')" />
  449.             </xsl:call-template>
  450.         </xsl:variable>
  451.         <xsl:variable name="border-style" select="substring-before(substring-after($border_properties, ' '), ' ')" />
  452.         <xsl:variable name="border-color" select="substring-after(substring-after($border_properties, ' '), ' ')" />
  453. <!--
  454.         <xsl:message>border-width:<xsl:value-of select="$border-width" /></xsl:message>
  455.         <xsl:message>border-style:<xsl:value-of select="$border-style" /></xsl:message>
  456.         <xsl:message>border-color:<xsl:value-of select="$border-color" /></xsl:message>
  457.  -->
  458.  
  459.         <!-- Dash, Dot, DashDot, DashDotDot, SlantDashDot are not supported yet -->
  460.         <xsl:attribute name="ss:LineStyle">
  461.             <xsl:choose>
  462.                 <xsl:when test="$border-style = 'none'">None</xsl:when>
  463.                 <xsl:when test="$border-style = 'double'">Double</xsl:when>
  464.                 <xsl:otherwise>Continuous</xsl:otherwise>
  465.             </xsl:choose>
  466.         </xsl:attribute>
  467.  
  468.         <xsl:attribute name="ss:Weight">
  469.             <xsl:choose>
  470.                 <!-- 0: Hairline -->
  471.                 <xsl:when test="$border-width <= 0.002">0</xsl:when>
  472.                 <!-- 1: Thin -->
  473.                 <xsl:when test="$border-width <= 0.035">1</xsl:when>
  474.                 <!-- 2: Medium -->
  475.                 <xsl:when test="$border-width <= 0.088">2</xsl:when>
  476.                 <!-- 3: Thick -->
  477.                 <xsl:otherwise>3</xsl:otherwise>
  478.             </xsl:choose>
  479.         </xsl:attribute>
  480.  
  481.         <xsl:attribute name="ss:Color">
  482.             <xsl:choose>
  483.                 <xsl:when test="$border-color"><xsl:value-of select="$border-color" /></xsl:when>
  484.                 <xsl:otherwise>Automatic</xsl:otherwise>
  485.             </xsl:choose>
  486.         </xsl:attribute>
  487.     </xsl:template>
  488.  
  489.  
  490.     <xsl:template name="Font">
  491.         <xsl:param name="styleProperties" />
  492.  
  493.         <!-- An empty font element, might overwrite parents setting by
  494.              the default attributes -->
  495.         <xsl:if test="$styleProperties/@style:font-weight or
  496.                       $styleProperties/@fo:color or
  497.                       $styleProperties/@style:font-name or
  498.                       $styleProperties/@fo:font-style or
  499.                       $styleProperties/@style:text-outline or
  500.                       $styleProperties/@style:text-shadow or
  501.                       $styleProperties/@style:font-size or
  502.                       $styleProperties/@style:text-line-through-style or
  503.                       $styleProperties/@style:text-underline-type or
  504.                       $styleProperties/@style:text-position">
  505.  
  506.  
  507.             <xsl:element name="Font">
  508.                 <xsl:if test="$styleProperties/@fo:font-weight = 'bold'">
  509.                     <xsl:attribute name="ss:Bold">1</xsl:attribute>
  510.                 </xsl:if>
  511.                 <xsl:if test="$styleProperties/@fo:color">
  512.                     <xsl:attribute name="ss:Color"><xsl:value-of select="$styleProperties/@fo:color" /></xsl:attribute>
  513.                 </xsl:if>
  514.                 <xsl:if test="$styleProperties/@style:font-name">
  515.                     <xsl:attribute name="ss:FontName"><xsl:value-of select="$styleProperties/@style:font-name" /></xsl:attribute>
  516.                 </xsl:if>
  517.                 <xsl:if test="$styleProperties/@fo:font-style = 'italic'">
  518.                     <xsl:attribute name="ss:Italic">1</xsl:attribute>
  519.                 </xsl:if>
  520.                 <xsl:if test="$styleProperties/@style:text-outline = 'true'">
  521.                     <xsl:attribute name="ss:Outline">1</xsl:attribute>
  522.                 </xsl:if>
  523.                 <xsl:if test="$styleProperties/@style:text-shadow = 'shadow'">
  524.                     <xsl:attribute name="ss:Shadow">1</xsl:attribute>
  525.                 </xsl:if>
  526.                 <xsl:if test="$styleProperties/@fo:font-size">
  527.                     <xsl:attribute name="ss:Size">
  528.                         <xsl:call-template name="convert2pt">
  529.                             <xsl:with-param name="value" select="$styleProperties/@fo:font-size" />
  530.                         </xsl:call-template>
  531.                     </xsl:attribute>
  532.                 </xsl:if>
  533.                 <xsl:if test="$styleProperties/@style:text-line-through-style and $styleProperties/@style:text-line-through-style != 'none'">
  534.                     <xsl:attribute name="ss:StrikeThrough">1</xsl:attribute>
  535.                 </xsl:if>
  536.                 <xsl:if test="$styleProperties/@style:text-underline-type and $styleProperties/@style:text-underline-type != 'none'">
  537.                     <xsl:attribute name="ss:Underline">
  538.                         <xsl:choose>
  539.                             <xsl:when test="$styleProperties/@style:text-underline-type = 'double'">Double</xsl:when>
  540.                             <xsl:otherwise>Single</xsl:otherwise>
  541.                         </xsl:choose>
  542.                     </xsl:attribute>
  543.                 </xsl:if>
  544.                 <xsl:if test="$styleProperties/@style:text-position">
  545.                     <xsl:attribute name="ss:VerticalAlign">
  546.                         <xsl:choose>
  547.                             <xsl:when test="substring-before($styleProperties/@style:text-position, '% ') > 0">Superscript</xsl:when>
  548.                             <xsl:otherwise>Subscript</xsl:otherwise>
  549.                         </xsl:choose>
  550.                     </xsl:attribute>
  551.                 </xsl:if>
  552.             </xsl:element>
  553.         </xsl:if>
  554.     </xsl:template>
  555.  
  556.     <xsl:template name="Interior">
  557.         <xsl:param name="styleProperties" />
  558.         <xsl:if test="$styleProperties/@fo:background-color and not($styleProperties/@fo:background-color = 'transparent')">
  559.             <xsl:element name="Interior">
  560.                 <xsl:attribute name="ss:Color">
  561.                     <xsl:value-of select="$styleProperties/@fo:background-color" />
  562.                 </xsl:attribute>
  563.                 <!-- Background color (i.e. Interior/ss:Color) not shown without ss:Pattern (or with 'none')
  564.                 Therefore a default is set -->
  565.                 <xsl:attribute name="ss:Pattern">Solid</xsl:attribute>
  566.             </xsl:element>
  567.         </xsl:if>
  568.     </xsl:template>
  569.  
  570. </xsl:stylesheet>
  571.